package com.aplikata.evok.dao;

import org.springframework.stereotype.Repository;

import com.aplikata.constants.ConstantsMsg;
import com.aplikata.dao.PublicDaoImpl;
import com.aplikata.evok.bo.DoctorSchedule;
import com.aplikata.evok.bo.Patient;
import com.aplikata.exception.CustomException;
import com.aplikata.util.FacesUtil;

/** 
* @ClassName: DoctorScheduleDaoImpl 
* @Description: TODO
* @author Huyun
* @date Sep 18, 2012 9:54:32 AM 
*  
*/
@Repository("doctorScheduleDao")
public class DoctorScheduleDaoImpl extends PublicDaoImpl<DoctorSchedule, Long> implements DoctorScheduleDao {

	@Override
	public void validate(DoctorSchedule schedule) throws Exception{
		if(schedule == null)
			return;
		
		if(schedule.getDomainPatient() == null){
			throw new CustomException(ConstantsMsg.MSG_REQUIRE, new Object[]{FacesUtil.getMessage(Patient.LB_TITLE)});
		}
		if(schedule.getDoctor() == null){
			throw new CustomException(ConstantsMsg.MSG_REQUIRE, new Object[]{FacesUtil.getMessage(Patient.LB_TITLE)});
		}
		if(schedule.getStatus() == null){
			throw new CustomException(ConstantsMsg.MSG_REQUIRE, new Object[]{FacesUtil.getMessage("default_status")});
		}
		if(schedule.getTimeFrom() == null){
			throw new CustomException(ConstantsMsg.MSG_REQUIRE, new Object[]{FacesUtil.getMessage("default_from")});
		}
		if(schedule.getTimeTo() == null){
			throw new CustomException(ConstantsMsg.MSG_REQUIRE, new Object[]{FacesUtil.getMessage("default_to")});
		}
	}
}
